import java.awt.*;
import java.awt.event.*;

import java.util.*;
import javax.swing.*;


public class Menu implements ActionListener
{
	protected ArrayList<JButton> buttons= new ArrayList<JButton>();
//	protected JButton play, generateWorld, exit;
	protected int action;
	protected JButton play = new JButton("Play JTerraria");
	protected JButton generateWorld = new JButton("Generate a new world");
	protected JButton exit = new JButton("Exit");
	public Menu()
	{
		JFrame start = new JFrame();
		start.setLayout(new GridLayout(3,1));
		start.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		buttons.add(play);
		buttons.add(generateWorld);
		buttons.add(exit);
		for(JButton b:buttons)
		{
			b.addActionListener(this);
			start.add(b);
		}
		start.setSize(300,150);
		start.setVisible(true);
		start.setResizable(false);
	}
	public int go()
	{
		action = -1;
		while (action == -1)
		{
			try{Thread.sleep(1);}catch(Exception e){}
		}
		return action;
	}
	public void actionPerformed(ActionEvent e)
	{
		Object o = e.getSource();
		if(o==exit){action = 0;}
		else if (o==generateWorld){action = 1;}
		else if (o==play){action = 2;}
	}
    public void playing()
    {
    }
    public void generateWorld()
    {
    }
}
